﻿using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.Xpo;

namespace Component
{
    public class MenuDB:Base
    {
        /// <summary>
        /// public static XPCollection<ContentManagement> GetAll()
        /// </summary>
        /// <returns>XPCollection<ContentManagement></returns>
        public static XPCollection<Menu> GetAll(bool admin)
        {
            XPCollection<Menu> _xpContentManagement = new XPCollection<Menu>(KetNoiCSDL.session);
            if (admin == false)
                _xpContentManagement.Filter = DevExpress.Data.Filtering.CriteriaOperator.Parse("Active=true ");
            _xpContentManagement.Sorting = SetupSort(ColumMenu._Priority, true);
            return _xpContentManagement;
        }
        /// <summary>
        /// public static ContentManagement GetObjectByid(int id)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Menu GetObjectByid(int id, bool admin)
        {
            XPCollection<Menu> _xpContentManagement = new XPCollection<Menu>(KetNoiCSDL.session);
            _xpContentManagement.Filter = FilterAll(admin);
            return _xpContentManagement.Lookup(id);
        }
    }
}
